Skip to content

[codex] Render deprecated API key scopes#2946

Merged
ChiragAgg5k merged 3 commits intomainfrom
codex/render-deprecated-api-key-scopes
Mar 30, 2026
Merged

[codex] Render deprecated API key scopes#2946
ChiragAgg5k merged 3 commits intomainfrom
codex/render-deprecated-api-key-scopes

Conversation

@ChiragAgg5k
Copy link
Copy Markdown
Member

@ChiragAgg5k ChiragAgg5k commented Mar 30, 2026

Summary

Render deprecated API key scopes in the scope picker instead of filtering them out, and show a Deprecated badge next to legacy entries.

What Changed

  • added a shared ScopeDefinition type for API key scope definitions
  • marked legacy scope entries such as collections.*, attributes.*, and documents.* as deprecated
  • updated the API key scopes UI to render all scopes, including deprecated ones
  • added a Deprecated badge next to deprecated scope options
  • updated the API key details form so switching between legacy and newer scope names is treated as a real scope change

Why

Deprecated scopes were still valid for existing API keys, but the UI hid them during rendering. That made older scopes invisible in the picker and prevented clearly communicating their status to users.

Impact

Users can now see deprecated scopes during API key creation/editing, with a clear visual indication that those scopes are deprecated.

Validation

  • bun run lint passed with existing repo warnings
  • bun run check failed due existing repo-wide type errors unrelated to this diff
  • bun run build failed due existing missing exports from @appwrite.io/console unrelated to this diff
  • bun run test could not run because package.json does not define a test script

Summary by CodeRabbit

  • Improvements
    • Added visual deprecation indicators for database-related scopes (collections, attributes, documents) in the API key scope configuration interface.
    • Simplified the scope selection and filtering mechanism for improved clarity when managing API key scopes.

@ChiragAgg5k ChiragAgg5k marked this pull request as ready for review March 30, 2026 03:05
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Mar 30, 2026

Warning

Rate limit exceeded

@ChiragAgg5k has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 17 minutes and 35 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 17 minutes and 35 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 123d763c-12fa-4508-867f-ab5673e84e2d

📥 Commits

Reviewing files that changed from the base of the PR and between 68ee7a8 and 8a7736c.

📒 Files selected for processing (2)
  • src/routes/(console)/project-[region]-[project]/overview/(components)/table.svelte
  • src/routes/(console)/project-[region]-[project]/overview/api-keys/scopes.svelte

Walkthrough

This pull request introduces a new ScopeDefinition type that extends scope objects with an optional deprecated boolean flag. Three database-related scopes (collections.*, attributes.*, documents.*) are marked as deprecated. Two components are updated to handle this deprecation: one adds a visual "Deprecated" badge for deprecated scopes, and another removes legacy scope compatibility logic to simplify scope comparison and filtering by using exact scope identity matches instead of scope variants.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly describes the main change: rendering deprecated API key scopes with a visual badge, which aligns with the primary objective and changes across all modified files.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/render-deprecated-api-key-scopes

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Mar 30, 2026

Greptile Summary

This PR makes deprecated API key scopes (the legacy collections.*, attributes.*, and documents.* families) visible in the scope picker instead of silently filtering them out, and adds a "Deprecated" badge next to each. The approach is sound — the ScopeDefinition type addition and direct-comparison change in keyDetails.svelte are clean — but two issues arise from the fact that deprecated scopes are now first-class, independently selectable items while the rest of the codebase still treats them as interchangeable aliases:

  • Category bulk-select adds deprecated scopes unintentionally: onCategoryChange iterates over all filteredScopes including deprecated entries. Clicking the Database category header to select all will activate collections.*, attributes.*, and documents.* alongside the current scopes, so a user creating a new key could unknowingly grant six deprecated scopes they never explicitly chose.
  • Scope count in the table becomes stale: table.svelte's getApiKeyScopeCount still calls getEffectiveScopes, which normalises legacy scope names to their current equivalents and deduplicates. If a user now selects both collections.read and tables.read, two scopes are stored but the table would show "1 Scope".

Confidence Score: 4/5

Safe to merge after addressing the category bulk-toggle and scope count display issues.

Two P1 findings exist: the 'select all' category action silently adds deprecated scopes to new keys, and the scope count badge in the table under-reports when both a deprecated scope and its newer equivalent are selected. Resolving them is straightforward before merging.

src/routes/(console)/project-[region]-[project]/overview/api-keys/scopes.svelte and table.svelte (unchanged in PR) need attention for the onCategoryChange bulk-toggle and getApiKeyScopeCount count inconsistency.

Important Files Changed

Filename Overview
src/lib/constants.ts Extracted a shared ScopeDefinition type, added deprecated?: boolean to legacy scope entries (collections., attributes., documents.*), and applied ScopeDefinition[] to cloudOnlyBackupScopes. Clean and correct.
src/routes/(console)/project-[region]-[project]/overview/api-keys/scopes.svelte Removed the legacy-prefix filter and compat-mapping helpers so all scopes (including deprecated) are rendered with a Badge. onCategoryChange bulk-toggles deprecated scopes unintentionally, and the scope count in table.svelte becomes inconsistent.
src/routes/(console)/project-[region]-[project]/overview/(components)/keyDetails.svelte Removed getEffectiveScopes usage for the Update button's disabled logic; the direct symmetricDifference comparison now treats switching between legacy and newer scope names as a real change, which aligns with the PR goal.

Comments Outside Diff (1)

  1. src/routes/(console)/project-[region]-[project]/overview/api-keys/scopes.svelte, line 8-25 (link)

    P1 Scope count in table becomes inaccurate when legacy and newer scopes coexist

    getEffectiveScopes (still exported here and imported by table.svelte's getApiKeyScopeCount) normalises legacy names to their current equivalents and deduplicates via a Set. Now that the picker allows independent selection of both deprecated and current scope names, a user who checks both collections.read and tables.read would store two scope strings, but the table would display 1 Scope (both normalise to tables.read).

    Either update getApiKeyScopeCount in table.svelte to use apiKey.scopes.length directly, or have getEffectiveScopes stop deduplicating deprecated-vs-current pairs now that they are treated as distinct selections.

Reviews (1): Last reviewed commit: "render deprecated api key scopes" | Re-trigger Greptile

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/lib/constants.ts (1)

158-163: Make category a shared union instead of a free-form string.

The picker filters this catalog by category with string equality, so a typo here would just make a scope disappear from the UI with no type error. Reusing a shared ScopeCategory union/const list would let TS validate the catalog and remove the duplicated category list in the component.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/lib/constants.ts` around lines 158 - 163, Change the free-form string
"category" on the exported type ScopeDefinition to a shared union type by
introducing an exported const array (e.g., ScopeCategories) and deriving a type
alias ScopeCategory = typeof ScopeCategories[number], then update
ScopeDefinition.category to use ScopeCategory instead of string; update any
catalog entries to use one of the allowed values and replace the duplicated
category list in the picker component to import and use
ScopeCategories/ScopeCategory for filtering and validation (refer to
ScopeDefinition, category, ScopeCategories/ScopeCategory).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In
`@src/routes/`(console)/project-[region]-[project]/overview/api-keys/scopes.svelte:
- Around line 173-180: The Checkbox control (Selector.Checkbox) currently only
renders the scope name/description while the deprecation notice is in a sibling
Badge, so assistive tech won't announce it; update the Checkbox to expose the
deprecated state by either appending " (Deprecated)" to the label or by adding a
description/aria-describedby that includes the deprecation text when
scope.deprecated is true (use scope.scope, scope.description, and
scope.deprecated to build the string), ensuring the Badge remains but is
associated via an id if using aria-describedby so screen readers hear the
deprecated status alongside the label/description; keep activeScopes binding
unchanged.

---

Nitpick comments:
In `@src/lib/constants.ts`:
- Around line 158-163: Change the free-form string "category" on the exported
type ScopeDefinition to a shared union type by introducing an exported const
array (e.g., ScopeCategories) and deriving a type alias ScopeCategory = typeof
ScopeCategories[number], then update ScopeDefinition.category to use
ScopeCategory instead of string; update any catalog entries to use one of the
allowed values and replace the duplicated category list in the picker component
to import and use ScopeCategories/ScopeCategory for filtering and validation
(refer to ScopeDefinition, category, ScopeCategories/ScopeCategory).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 80e69249-55ea-4ee3-96a0-2d0bb4f3f746

📥 Commits

Reviewing files that changed from the base of the PR and between 00d9765 and 68ee7a8.

📒 Files selected for processing (3)
  • src/lib/constants.ts
  • src/routes/(console)/project-[region]-[project]/overview/(components)/keyDetails.svelte
  • src/routes/(console)/project-[region]-[project]/overview/api-keys/scopes.svelte

@ChiragAgg5k ChiragAgg5k merged commit 692c13d into main Mar 30, 2026
4 checks passed
@ChiragAgg5k ChiragAgg5k deleted the codex/render-deprecated-api-key-scopes branch March 30, 2026 03:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants